package com.ms.oschina.viewholder;

import android.graphics.Color;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.View;
import android.widget.TextView;

import com.ms.oschina.R;
import com.ms.oschina.base.BaseViewHolder;
import com.ms.oschina.bean.Active;
import com.ms.oschina.bean.Active.ObjectReply;
import com.ms.oschina.util.RichTextHelper;
import com.ms.oschina.util.StringUtils;
import com.ms.oschina.util.UiUtils;
import com.ms.oschina.util.RichTextHelper.TextClickableSpan;
import com.ms.oschina.view.CircleImageView;
import com.ms.oschina.view.TextViewFixTouchConsume;
import com.squareup.picasso.Picasso;

public class FriendsViewHolder extends BaseViewHolder<Active> {
	private CircleImageView civFriendsUserAvatar;
	private TextView tvFriendsUserName;
	private TextView tvFriendsTime;
	private TextView tvFriendsDynamic;
	private TextViewFixTouchConsume tvFriendsCommentContent;

	/**
	 * Find the Views in the layout<br />
	 * <br />
	 * Auto-created  by Android Layout Finder
	 * (http://www.buzzingandroid.com/tools/android-layout-finder)
	 */
	private void findViews(View view) {
		civFriendsUserAvatar = (CircleImageView) view
				.findViewById(R.id.civ_friends_userAvatar);
		tvFriendsUserName = (TextView) view
				.findViewById(R.id.tv_friends_userName);
		tvFriendsTime = (TextView) view.findViewById(R.id.tv_friends_time);
		tvFriendsDynamic = (TextView) view
				.findViewById(R.id.tv_friends_dynamic);
		tvFriendsCommentContent = (TextViewFixTouchConsume) view
				.findViewById(R.id.tv_friends_commentContent);
	}

	@Override
	public View initView() {
		View view = UiUtils.inflate(R.layout.item_friends);
		findViews(view);
		return view;
	}

	@Override
	public void setData(int position, Active data) {
//		ObjectReply objReply = data.getObjectReply();
//		String objectName = objReply.getObjectName();
//		String objectBody = objReply.getObjectBody();
//		objectBody = objectBody.replace("\n", "");

	tvFriendsTime.setText(StringUtils.friendly_time(data.getPubDate()));
	tvFriendsUserName.setText(data.getAuthor());

	RichTextHelper.setTextRecombinationContent(tvFriendsCommentContent,
			data.getMessage());

	String portrait = data.getPortrait();
	if (!TextUtils.isEmpty(portrait)) {
		Picasso.with(UiUtils.getContext()).load(portrait)
				.placeholder(R.drawable.widget_dface)
				.into(civFriendsUserAvatar);
	}
	}

}
